package hello;



/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */



import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;


public class Pantalla extends Canvas implements Runnable{

    private Sprite robo;
    private Image imagen;
    public Pantalla(){
        //instanciamos (creamos) el objeto ball a partir de la clase Sprite
        robo= new Sprite(getWidth()/2,getHeight()/2,20,20);

    }
    private void initialize () {}
    
    public void run(){
        while(true){
            //actualizamos la posicion de la bola
            robo.compute(getWidth(),getHeight());
            //forzamos el repintado de la pantalla
            repaint();
            serviceRepaints();
            try {
                Thread.sleep(30);
            } catch (InterruptedException e) {
            }
        }
    }
    //metodo de la clase canvas para pintar en pantalla
    public void paint(Graphics g){
        //pintamos la bola en pantalla
        int w = getWidth ();
                int h = getHeight ();
                // Borrar la pantalla
                g.setColor(0x404040);
                g.fillRect(0, 0, getWidth(), getHeight());

				//pone imagen
				 try
                {
                        imagen = Image.createImage("/icons/logo.png");
                }
                catch (Exception e)
                {
                        System.err.println("error: " + e);
                }
                 g.drawImage(imagen, getWidth()/2,getHeight()/4, Graphics.HCENTER | Graphics.TOP);
                // Poner texto
                Font fuente = Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD, Font.SIZE_MEDIUM);
                g.setFont(fuente);
                g.setColor(0xb20000);
                g.drawString("Bienvenidos a Robo ", getWidth() / 2, 20, Graphics.TOP | Graphics.HCENTER);
                g.drawString("Creado por: ", getWidth() / 2, getHeight()-60, Graphics.TOP | Graphics.HCENTER);
                g.drawString("Raul Rivera ,Rodrigo Kestler" , getWidth() / 2, getHeight()-50, Graphics.TOP | Graphics.HCENTER);
				
				if(robo.cambio()){
                 robo.draw3(g);
				}
				else{
				 robo.draw4(g);
				 }
    }
}
